using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BookingDB.Models.Mapping
{
    public class PersonMap : EntityTypeConfiguration<EntityPerson>
    {
        public PersonMap()
        {
            // Primary Key
            this.HasKey(t => t.cpr);

            // Properties
            this.Property(t => t.cpr)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.address)
                .HasMaxLength(50);

            this.Property(t => t.phoneNo)
                .HasMaxLength(8);

            this.Property(t => t.firstName)
                .HasMaxLength(50);

            this.Property(t => t.lastName)
                .HasMaxLength(20);

            this.Property(t => t.email)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Person");
            this.Property(t => t.cpr).HasColumnName("cpr");
            this.Property(t => t.address).HasColumnName("address");
            this.Property(t => t.phoneNo).HasColumnName("phoneNo");
            this.Property(t => t.firstName).HasColumnName("firstName");
            this.Property(t => t.lastName).HasColumnName("lastName");
            this.Property(t => t.email).HasColumnName("email");
            this.Property(t => t.postalCode_Id).HasColumnName("postalCode_Id");
        }
    }
}
